<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>将句子排序</title>
</head>
<body>
  <script>
    function fn(s) {
      s = s.split(' ');
      s.sort((a, b) => a[a.length - 1] - b[b.length - 1]);
      s = s.map(item => item.slice(0, item.length - 1));
      return s.join(' ');
    }
    console.log(fn('is2 sentence4 This1 a3'))
  </script>
</body>
</html>